


project_path=lis_international/twl/ncs/resource
branch=zhangqiang
fileType=tar.gz
project_id=`echo "${project_path}" | sed 's#/#%2F#g'`
resource_filename="${project_path##*/}.${fileType}"
curl -# -H "PRIVATE-TOKEN: glpat-bUhMCV3n6EuShLWc7_ky" -o ${project_path##*/}.${fileType} "http://gitlab.sinosoft-open.com:11192/api/v4/projects/${project_id}/repository/archive.${fileType}?sha=${branch}"
tar -zxf "${resource_filename}"
resource_dirname=`tar -tf "${resource_filename}" | head -1 | tr -d '/'`


package_dir=${WORKSPACE}/${resource_dirname}/package
tool_dir=${JENKINS_HOME}/tool

if [[ ! -e ${tool_dir} ]];then
    mkdir -p ${tool_dir}
fi
ls -lh ${tool_dir}

if [[ ! -e ${HOME}/bin ]];then
    mkdir ${HOME}/bin
fi
ls -lh ${HOME}/bin

cd ${tool_dir}
tar -zxf ${package_dir}/zlib-1.3.1.tar.gz -C ${tool_dir}
cd ${tool_dir}/zlib-1.3.1
./configure --prefix=${tool_dir}/zlib
make
make install


cd ${tool_dir}
tar -zxf ${package_dir}/openssl-1.1.1.tar.gz -C ${tool_dir}
cd ${tool_dir}/openssl-1.1.1
./config --prefix=${tool_dir}/openssl
make
make install
LDFLAGS="-L${tool_dir}/openssl/lib" CPPFLAGS="-I${tool_dir}/openssl/include"


cd ${tool_dir}
tar -zxf ${package_dir}/curl-7.88.1.tar.gz -C ${tool_dir}
cd ${tool_dir}/curl-7.88.1
./configure --prefix=${tool_dir}/curl --with-openssl
make
make install


cd ${tool_dir}
tar -zxf ${package_dir}/git-2.46.0.tar.gz -C ${tool_dir}
cd ${tool_dir}/git-2.46.0
./configure --prefix=${tool_dir}/git --with-curl=${tool_dir}/curl --with-openssl=${tool_dir}/openssl --with-zlib=${tool_dir}/zlib LDFLAGS="-L${tool_dir}/openssl/lib" CPPFLAGS="-I${tool_dir}/openssl/include"
make 
make install
#ln -sf ${tool_dir}/git/bin/git ${HOME}/bin/git 

cd ${tool_dir} 
tar -zxf ${package_dir}/apache-maven-3.6.3-bin.tar.gz -C ${tool_dir}
# ln -sf ${tool_dir}/apache-maven-3.6.3/bin/mvn ${HOME}/bin/mvn

cd ${tool_dir} 
tar -zxf ${package_dir}/jdk-8u202-linux-x64.tar.gz -C ${tool_dir}

ls -lh ${tool_dir}